package com.lc.activiti.process;

import com.lc.activiti.config.Result;
import com.lc.activiti.process.service.TaskActionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 流程任务
 * @Description:
 * @author: 骆超
 * @date: 2021/6/2 8:46
 */
@RestController
@RequestMapping("/task")
@Api(tags = "流程任务")
public class TaskController {
    @Resource
    private TaskActionService taskActionService;

    /**
     * 获取审核任务
     *
     * @param auditBean 参数说明
     * @return com.lc.activiti.config.Result
     * @author 骆超
     * @date 2021/6/4
     */
    @PostMapping(value = "getTasks")
    @ApiOperation("获取审核任务")
    public Result getTasks(@RequestBody AuditBean auditBean) {
        return taskActionService.getTasks(auditBean);
    }

    /**
     * 任务审核
     * @param auditBean 审核意见
     * @return com.lc.activiti.config.Result
     * @author 骆超
     * @date 2021/6/21
     */
    @PostMapping("auditTask")
    @ApiOperation("任务审核")
    public Result auditTask(@RequestBody AuditBean auditBean) throws Exception {
        return taskActionService.auditTask(auditBean);
    }

    /**
     * 获取流程图并高亮
     * @param response  HttpServletResponse 响应
     * @param auditBean 封装对象
     * @author 骆超
     * @date 2021/6/15
     */
    @PostMapping("getAuditedImg")
    @ApiOperation("获取流程图并高亮")
    public void getAuditedImg(HttpServletResponse response, @RequestBody AuditBean auditBean) throws IOException {
        taskActionService.getAuditedImg(response,auditBean);
    }

    /**
     * 任务转办
     * @author 骆超
     * @date 2021/6/25
     * @param auditBean 参数说明
     * @return com.lc.activiti.config.Result
     */
    @PostMapping("transferTask")
    @ApiOperation("任务转办")
    public Result transferTask(@RequestBody AuditBean auditBean) throws Exception {
        return taskActionService.transferTask(auditBean);
    }


    /**
     * 流程撤回
     * @author 骆超
     * @date 2021/6/29
     * @param auditBean 参数说明
     * @return com.lc.activiti.config.Result
     */
    @PostMapping("recallProcess")
    @ApiOperation("流程撤回")
    public Result recallProcess(@RequestBody AuditBean auditBean) throws Exception {
        return taskActionService.recallProcess(auditBean);
    }

}
